package com.consorzioimpresa.resuite.domain

class SearchController {

	def grailsApplication
	
    def index = { }
	
	def search ={
		if(params.q && !params.q.isEmpty() && params.clazz && !params.clazz.isEmpty()){
		def dc = grailsApplication.getDomainClass(params.clazz)
		Class<?> entity = dc.clazz 
			render(view: "/${params.entity}/search", model: [searchResult: entity.search(params.q,params),params:params])
		}else{
				params.q="null"
				render(view: "/${params.entity}/search", model: [params:params])
			}
			
	}
}
